#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
int Max(int *p)
{
	int M = 1;
	for (int i = 1; i <= 1000; i++)
	{
		if (*(p + i) >= *(p + M))
		{
			M = i;
		}
	}
	return M;
}

int main()
{
	int n = 0;
	scanf("%d", &n);
	int num[1001] = { 0 };
	for (int i = 0; i < n; i++)
	{
		int a[10] = { 0 };
		int k = 0;
		scanf("%d", &k);
		for (int j = 0; j < k; j++)
		{
			scanf("%d", &a[j]);
		}
		for (int j = 0; j < k; j++)
		{
			num[a[j]]++;
		}
	}
	int max = Max(num);
	printf("%d %d", max, num[max]);
	return 0;
}